1 Objet

explorer Lidar et R pour les arbres

https://r-lidar.github.io/lidRbook/io.html

et surtout en très clair

https://orbi.uliege.be/bitstream/2268/307897/5/R_GIS_04_lidR.pdf

On cherche d’abord la localisation x y précise des arbres

2 Environnement

2.1 Librairies

library(sf)
## Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(lidR)
## 
## Attachement du package : 'lidR'
## L'objet suivant est masqué depuis 'package:sf':
## 
##     st_concave_hull
library(rgl)# pour visu 3d
library(mapsf)
library(leaflet)
library(mapview)

2.2 Ressources

source : https://whitschroder.github.io/remote-sensing/lidr.html#cloth-simulation-function-csf

https://r-lidar.github.io/lidRbook/dtm.html

traduction rapide du manuel lidR

https://r-lidar.github.io/lidRbook/io.html

donnée position x y z intensité rang angle d’incidence

laz format compressé de las

l’objet est constitué de l’en tête et du nuage de point

2.3 Chemins

Les fichiers de téléchargement sont lourds, on les met dans data/gros et on modifie le gitignore pour les exclure

Récupération des formes pour couper

zone <- st_read("data/zone.gpkg")
## Reading layer `zoneExtraction' from data source 
##   `C:\Users\tachasa\10_photosGPS\data\zone.gpkg' using driver `GPKG'
## Simple feature collection with 1 feature and 1 field
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: 2.480062 ymin: 48.8885 xmax: 2.483405 ymax: 48.89035
## Geodetic CRS:  WGS 84
mapview(zone)
zone <- st_transform(zone, 2154)

3 Extraction mare Ă  la veuve

lasf <- dir("data/gros", "*.laz")
for (f in lasf) {
  las <- readLAS(paste0("data/gros/",f), select = "xyz")
  sel <- clip_roi(las, zone)
  writeLAS(sel, paste0( "data/",f,".las"))
}
lasf <- dir("data/", "*.las")
sel <- readLAS(paste0("data/", lasf [1]))
sel1 <- readLAS(paste0("data/", lasf [2]))
tot <- rbind(sel, sel1)
writeLAS(tot, "data/gros/tot.las")

4 présenter

Tous les points sont à zéro

tot <- readLAS("data/gros/tot.las")
# tous les points
df <- payload(tot)
table(df$Classification)

4.1 vue 2d

library(ggplot2)
ggplot(payload(tot), aes(X,Z, color = Z)) + 
  geom_point(size = 0.5) + 
  coord_equal() + 
  theme_minimal() +
  scale_color_gradientn(colours = height.colors(50))

4.2 rgl

tot <- readLAS("data/gros/tot.las")
plot(tot, bg="white")
rglwidget()

5 Modèle numérique de canopée

On va au plus simple, mais il y a des subtilités par rapport aux données NODATA

tot <- readLAS("data/gros/tot.las")
library(terra)
chm <- rasterize_canopy(tot, res=1, p2r())
plot (chm)

writeRaster(chm, "data/chm.tif", overwrite=TRUE)

6 localiser les arbres

on applique un lmf local maximum filter

f <- function (x) { x * 0.05 + 2}
ws_args <- list(x ="Z")
ml <- locate_trees(tot, lmf(hmin = 12, f, ws_args = ws_args, shape = "circular"))
plot(chm)
plot(ml$geometry, add = T)

points voisins : diametre 7 m semble convenir

ml <- locate_trees(tot, lmf(ws = 7))
plot(chm)
plot(ml$geometry, add = T)

x <- plot(tot, bf="white", size = 4)
add_treetops3d(x, ml)

7 segmentation

permet d’obtenir les arbres individuels

algo <- dalponte2016(chm, ml)
las <- segment_trees(tot, algo) # segment point cloud
plot(las, bg = "white", size = 4, color = "treeID") # visualize trees

arbre individuel

tree110 <- filter_poi(las, treeID == 110)
plot(tree110, size = 8, bg = "white")